﻿Imports System
Imports System.Collections.Generic
Imports System.Threading
Imports System.Workflow.ComponentModel

Namespace System.Workflow.Runtime
    Public Class WorkflowCompletedEventArgs
        Inherits WorkflowEventArgs
        ' Methods
        Friend Sub New(ByVal instance As WorkflowInstance, ByVal workflowDefinition As Activity)
            MyBase.New(instance)
            Me._outputParameters = New Dictionary([Of] String, Object)
            Me._originalWorkflowDefinition = workflowDefinition
            Me._workflowDefinition = Nothing
        End Sub


        ' Properties
        Public ReadOnly Property OutputParameters As Dictionary([Of] String, Object)
            Get
                Return Me._outputParameters
            End Get
        End Property

        Public ReadOnly Property WorkflowDefinition As Activity
            Get
                If (Me._workflowDefinition Is Nothing) Then
                    [Using] New WorkflowDefinitionLock(Me._originalWorkflowDefinition)
                        If (Me._workflowDefinition Is Nothing) Then
                            Dim activity As Activity = Me._originalWorkflowDefinition.Clone
                            Thread.MemoryBarrier
                            Me._workflowDefinition = activity
                        End If
                    End [Using]
                End If
                Return Me._workflowDefinition
            End Get
        End Property


        ' Fields
        Private _originalWorkflowDefinition As Activity
        Private _outputParameters As Dictionary([Of] String, Object)
        Private _workflowDefinition As Activity
    End Class
End Namespace

